/**
 ******************************************************************************
 * @author  泽耀科技 ASHINING
 * @version V3.0
 * @date    2016-10-08
 * @brief   CC1101配置H文件
 ******************************************************************************
 * @attention
 *
 * 官网	:	http://www.ashining.com
 * 淘宝	:	https://shop105912646.taobao.com
 * 阿里巴巴:	https://cdzeyao.1688.com
 ******************************************************************************
 */

#ifndef __CC1101_H__
#define __CC1101_H__

#include "cc1101_reg.h"
#include "main.h"
#include "stdint.h"


#define PA_TABLE                                                                                                       \
    {                                                                                                                  \
        0xc2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,                                                                \
    }

#define CC1101_GET_GDO0_STATUS() HAL_GPIO_ReadPin(GPIO0_GPIO_Port, GPIO0_Pin)
#define CC1101_GET_GDO2_STATUS() HAL_GPIO_ReadPin(GPIO2_GPIO_Port, GPIO2_Pin)

#define SPI_NSS_HIGH() HAL_GPIO_WritePin(SPI_NSS_GPIO_Port, SPI_NSS_Pin, GPIO_PIN_SET)
#define SPI_NSS_LOW() HAL_GPIO_WritePin(SPI_NSS_GPIO_Port, SPI_NSS_Pin, GPIO_PIN_RESET)

/** 枚举量定义 */
typedef enum
{
    TX_MODE,
    RX_MODE
} CC1101_ModeType;

typedef enum
{
    BROAD_ALL,
    BROAD_NO,
    BROAD_0,
    BROAD_0AND255
} CC1101_AddrModeType;

typedef enum
{
    BROADCAST,
    ADDRESS_CHECK
} CC1101_TxDataModeType;

void CC1101_Write_Cmd(uint8_t Command);
void CC1101_Write_Reg(uint8_t Addr, uint8_t WriteValue);
void CC1101_Write_Multi_Reg(uint8_t Addr, uint8_t *pWriteBuff, uint8_t WriteSize);
uint8_t CC1101_Read_Reg(uint8_t Addr);
void CC1101_Read_Multi_Reg(uint8_t Addr, uint8_t *pReadBuff, uint8_t ReadSize);
uint8_t CC1101_Read_Status(uint8_t Addr);
void CC1101_Set_Mode(CC1101_ModeType Mode);
void CC1101_Set_Idle_Mode(void);
void C1101_WOR_Init(void);
void CC1101_Set_Address(uint8_t Address, CC1101_AddrModeType AddressMode);
void CC1101_Set_Sync(uint16_t Sync);
void CC1101_Clear_TxBuffer(void);
void CC1101_Clear_RxBuffer(void);
void CC1101_Tx_Packet(uint8_t *pTxBuff, uint8_t TxSize, CC1101_TxDataModeType DataMode);
void CC1101_Output_Enable();
void CC1101_Output_Disable();
void CC1101_SetOutputLevel(uint8_t level);
uint8_t CC1101_Get_RxCounter(void);
uint8_t CC1101_Rx_Packet(uint8_t *RxBuff);
void CC1101_Reset(void);
void CC1101_Init(void);

#endif
